package com.wzdigit.wms.common.utils;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;

import java.lang.reflect.Field;

/**
 * Describe：判断对象中属性值是否全为空
 * return true 全为空 反之
 * @author zhangbw
 * @date 2020/1/13 14:19
 */
@Slf4j
public class ObjAllFieldsIsNullUtils {

    public static boolean checkObjAllFieldsIsNull(Object object) {
        if (null == object) {
            return true;
        }
        try {
        	Field declaredField = object.getClass().getDeclaredField("");
            for (Field f : object.getClass().getDeclaredFields()) {
                f.setAccessible(true);
                System.out.print(f.getName() + ":");
                System.out.println(f.get(object));
                if(StringUtils.equals("serialVersionUID",f.getName())){
                    continue;
                }
                if (f.get(object) != null && StringUtils.isNotBlank(f.get(object).toString())) {
                    return false;
                }
            }
        } catch (Exception e) {
            log.info("判断对象中属性值是否全为空 异常",e);
        }
        return true;
    }
}
